export default {
	namespaced: true,
	state: {
		address: uni.getStorageSync('address') || {},
		token: uni.getStorageSync('token') || {},
		userInfo: uni.getStorageSync('userInfo') || {},
		redirectInfo: {}
	},
	mutations: {

		setAddress(state, address) {
			state.address = address
			uni.setStorageSync('address', state.address)
		},
		// 修改用户信息
		getUserInfo(state, userInfo) {
			state.userInfo = userInfo
			uni.setStorageSync('userInfo', state.userInfo)
		},
		// 设置用户token
		setToken(state, token) {
			state.token = token
			uni.setStorageSync('token', state.token)
		},
		// 退出登录
		logout(state) {
			state.userInfo = {}
			uni.removeStorageSync('userInfo')
			state.token = ''
			uni.removeStorageSync('token')
		},
		//点击结算跳转后跳回来
		getrRedirectInfo(state, info) {
			state.redirectInfo = info
		}
	},
	actions: {},
	getters: {
		fullAddress: function(state) {
			if (!state.address.userName) return '暂无地址'
			return state.address.provinceName + state.address.cityName + state.address.countyName + state.address
				.detailInfo
		}
	}
}
